<?php


namespace Admin\Controller;

class GoodsatvalController extends AdminController {

    public function index(){
        $goodsatval = D('Goodsatval');

        $infos = $goodsatval->where("aid =".$_GET['id'])->select();
//dump($infos);
        $this->assign('aid',$_GET['id']);
        $this->assign('infos',$infos);
        $this->display();
    }


    public function add(){
        $goodsatval = D('Goodsatval');

        if(IS_POST){
//            dump(I());
            $z = $goodsatval->toadd(I());
            if($z){
                $this->success('添加成功', U('Goodsatval/index?id='.I('aid')));
            }else{
                $this->error('添加失败', U('Goodsatval/add?id='.I('aid')));
            }

        }else{
            $this->assign('aid',$_GET['id']);
            $this->display();
        }

    }

    //更新
    public function upd(){
        $goodsatval = D('Goodsatval');

        if(IS_POST){
            $z = $goodsatval->toupd(I());
            if($z){
                $this->success('修改成功', U('Goodsatval/index?id='.I('aid')));
            }else{
                $this->error('修改失败', U('Goodsatval/add?id='.I('aid')));
            }

        }else{
            $info = $goodsatval->find($_GET['id']);

            $this->assign('info',$info);
            $this->display();
        }

    }

    public function del($id = null){
        $goodsatval = D('Goodsatval');

        $z =  $goodsatval->todel($id);
        if($z){
            $this->success('删除成功', U('Goodsatval/index?id='.I('aid')));
        }else{
            $this->error('删除失败', U('Goodsatval/index?id='.I('aid')));
        }
    }




}
